# Build recipe for libelf-compat.
#
# Copyright (c) 2017 Matias Fonzo, <selk@dragora.org>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=libelf-compat
version=0.156c001
release=1

tarname=${program}-${version}.tar.xz

# Remote source(s)
fetch=http://ftp.barfooze.de/pub/sabotage/tarballs/$tarname

description="
ELF object file access library.

libelf lets you read, modify or create ELF files in an
architecture-independent way.  The library takes care of
size and endian issues.

This version of libelf comes from Sabotage Linux.
"

homepage=http://ftp.barfooze.de/pub/sabotage
license="GPLv2+, GPLv3+, LGPLv3"

# Source documentation
docs="AUTHORS COPYING* src/ChangeLog"
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"

    sed -i 's/-O3 //' Makefile
    echo "CFLAGS += $QICFLAGS -fPIC" > config.mak
    sed -i 's@HEADERS = src/libelf.h@HEADERS = src/libelf.h src/gelf.h@' Makefile

    make -j${jobs} prefix=/usr libdir=/usr/lib${libSuffix} \
     DESTDIR="$destdir" install

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}"
}

